<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统管理平台</title>
    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
        }

        /* 导航栏样式 */
        .navbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background-color: #333;
            padding: 10px 20px;
            color: white;
        }
        .navbar .logo img {
            height: 40px;
        }
        .navbar .system-name {
            flex: 1;
            text-align: center;
            font-size: 24px;
            font-weight: bold;
        }
        .navbar .titles a {
            text-decoration: none;
            color: white;
            margin: 0 10px;
            font-weight: bold;
        }
        .navbar .titles a:hover {
            text-decoration: underline;
        }

        /* 页面布局 */
        .main-container {
            display: flex;
            height: calc(100vh - 60px); /* 除去导航栏的高度 */
        }

        /* 左侧垂直菜单样式 */
        .sidebar {
            width: 200px;
            border-right: 1px solid #ccc;
            background-color: #f9f9f9;
            padding: 10px;
            box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
        }
        .menu-item {
            position: relative;
            cursor: pointer;
            padding: 10px;
            border-bottom: 1px solid #eee;
        }
        .menu-item:hover {
            background-color: #e0e0e0;
        }
        .menu-item:hover::after {
            content: attr(data-tooltip);
            position: absolute;
            left: 100%;
            top: 50%;
            transform: translateY(-50%);
            background-color: #333;
            color: white;
            padding: 5px 10px;
            border-radius: 4px;
            white-space: nowrap;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        }
        .submenu {
            display: none;
            background-color: #fff;
            padding-left: 20px;
            margin-top: 5px;
            border-left: 2px solid #ccc;
        }
        .submenu a {
            display: block;
            padding: 5px 0;
            color: #333;
            text-decoration: none;
        }
        .submenu a:hover {
            text-decoration: underline;
        }
        .menu-item.active .submenu {
            display: block;
        }

        /* 右侧内容框样式 */
        .content {
            flex: 1;
            padding: 20px;
            background-color: #fff;
            overflow-y: auto;
            box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
        }
        .content h1 {
            margin-top: 0;
        }
    </style>
</head>
<body>
<!-- 顶部导航栏 -->
<div class="navbar">
    <div class="logo">
        <img src="/image/校徽.png" alt="图标">
    </div>
    <div class="system-name">系统管理平台</div>
    <div class="titles">
        <a href="#home">首页</a>
        <a href="#about">关于</a>
        <a href="#contact">联系我们</a>
    </div>
</div>

<!-- 页面主体布局 -->
<div class="main-container">
    <!-- 左侧垂直菜单 -->
    <div class="sidebar">
        <div class="menu-item" data-tooltip="档案管理系统">
            人力资源管理模块
            <div class="submenu">
                <a href="#role" data-page="humanAdd.jsp">添加档案</a>
                <a href="#org" data-page="org.jsp">机构管理</a>
                <a href="#position" data-page="position.jsp">职位管理</a>
                <a href="#salary" data-page="salary.jsp">薪资项目管理</a>
            </div>
        </div>
        <div class="menu-item" data-tooltip="档案操作">
            档案管理
        </div>
        <div class="menu-item" data-tooltip="管理薪酬">
            薪酬管理
        </div>
        <div class="menu-item" data-tooltip="发放薪酬">
            薪酬发放
        </div>
    </div>

    <!-- 右侧内容框 -->
    <div class="content" id="content">
        <h1>欢迎</h1>
        <p>请选择左侧菜单中的功能。</p>
    </div>
</div>

<script>
    document.querySelectorAll('.submenu a').forEach(link => {
        link.addEventListener('click', function (e) {
            e.preventDefault();
            const page = this.getAttribute('data-page'); // 功能页面
            const script = page.replace('.jsp', '.js'); // 假设同名 JS 文件存在

            if (page) {
                fetch(page)
                    .then(response => response.text())
                    .then(data => {
                        const content = document.getElementById('content');
                        content.innerHTML = data;

                        // 动态加载功能页面的脚本
                        const scriptElement = document.createElement('script');
                        scriptElement.src = script;
                        scriptElement.onload = () => console.log(`${script} loaded`);
                        document.body.appendChild(scriptElement);
                    })
                    .catch(error => console.error('页面加载失败:', error));
            }
        });
    });
</script>
</body>
</html>